home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2001 / MacHack 2001.toast / pc / The Hacks / HFS- / SerialFSServ / GenericSerial.h < prev    next >
Encoding:
Text File  |  2001-06-23  |  2.8 KB  |  97 lines

  1. // GenericSerial.h
  2. // constants, message formats, etc... used on Palm & Mac
  3.  
  4.  
  5. // opcode definitions
  6. enum
  7. {
  8.     kDirEnumerate = 0,    // whats in a directory?
  9.     kFileCreate,        // create a file...
  10.     kDirCreate,
  11.     kFileOpen,            // Open a file
  12.     kFileClose,            // close a file
  13.     kFileRead,            // read bytes from a file
  14.     kFileWrite,            // write bytes from a file
  15.     kFileSeek,            // move file marker
  16.     kFileSize,            // how big is the file?
  17.     kFileResize,        // set file size
  18.     kFileRename,        // rename a file(!)
  19.     kFileDelete,        // delete a file
  20.     
  21.     kFileOpResult        // result code from a request.
  22. };
  23.  
  24. #define kMaxExtraDataSize    512
  25.  
  26. #define kCookieValue    'hack'
  27.  
  28. /* 
  29.     Message packet format.
  30.     
  31.     All messages consist of a packet of this format, 
  32.     optionally followed by a variable length data buffer.
  33.     Note: this structure aligns the same way on PPC (Mac) & 68k (Palm).
  34.     All requests are initiated by the "client".  
  35.     For every message the client sends the server, it will receive a message in response.
  36.     Read/write messages are limited to kMaxExtraDataSize bytes at a time, 
  37.     so large read/writes will be broken up into multiple messages.
  38. */
  39. typedef struct
  40. {
  41.     unsigned long    cookie;
  42.     
  43.     unsigned short    op;
  44.     unsigned short    dataSize;    // Amount of extra data present after this structure.
  45.     unsigned short    result;
  46.     unsigned short    reserved;
  47.     
  48.     long    param1;
  49.     long    param2;
  50.     long    param3;
  51.     long    param4;
  52. } MyPacket;
  53.  
  54.  
  55. // prototypes:  
  56. // Facilities provided by GenericSerial.c:
  57.  
  58. short RemoteFileRead(long filep, long numBytes, long *numBytesRead, char *bufP, char dataStoreBased, long offset);
  59. short RemoteFileWrite(long filep, long numBytes, long *numWritten, char *bufP);
  60.  
  61. short RemoteDirCreate(char *path);
  62. short RemoteFileCreate(char *path);
  63. short RemoteFileDelete(char *path);
  64. short RemoteFileOpen(char *path, long perm, long *filePP);
  65. short RemoteFileClose(long filep);
  66.  
  67. short RemoteFileSeek(long filep, short origin, unsigned short offset);
  68. short RemoteFileSize(long filep, long *size);
  69. short RemoteFileResize(long filep, long newsize);
  70.  
  71. short RemoteDirIterate(long dirP, long *iteratorP, char *buf, long *size, long *attr);
  72.  
  73. void ServeSomething(void);
  74.  
  75.  
  76. // Functions required by GenericSerial.c:
  77. short SerialRead(short numBytes, char *bufP);
  78. short SerialWrite(short numBytes, char *bufP);
  79.  
  80.  
  81. short LocalDirIterate(long dirP, unsigned long *iteratorP, char *buf, long *size, long *attr);
  82.  
  83. short LocalFileCreate(char *path);
  84. short LocalFileDelete(char *path);
  85. short LocalDirCreate(char *path);
  86.  
  87. short LocalFileOpen(char *path, long perm, long *filePP);
  88. short LocalFileClose(long filep);
  89.  
  90. short LocalFileRead(long filep, long numBytes, long *numBytesRead, char *bufP);
  91. short LocalFileWrite(long filep, long numBytes, long *numWritten, char *bufP);
  92.  
  93. short LocalFileSeek(long filep, short origin, unsigned short offset);
  94. short LocalFileSize(long filep, long *size);
  95. short LocalFileResize(long filep, long newsize);
  96.  
  97.